package com.gupaoedu.task.pattern.strategytask.schedule.scheduleport;

import java.util.HashMap;
import java.util.Map;

public class ScheduleStrategy {
    public static final String SCHEDULE_TYPE = "ScheduleType";
    public static final String SCHEDULE_TIMEOUT = "ScheduleTimeout";
    public static final String MISSION = "Mission";
    public static final String ALL_TIMEOUT = "AllTimeout";
    public static final String DEFAULT_TYPE = "ScheduleType";
    private static Map<String, Schedulement> scheduleStrategy = new HashMap<String, Schedulement>();

    static {
        scheduleStrategy.put(SCHEDULE_TYPE, new ScheduleType());
        scheduleStrategy.put(SCHEDULE_TIMEOUT, new ScheduleTimeout());
        scheduleStrategy.put(MISSION, new Mission());
        scheduleStrategy.put(ALL_TIMEOUT, new AllTimeout());
    }

    public static Schedulement get(String schdulingtype) {
        if (!scheduleStrategy.containsKey(schdulingtype)) {
            return scheduleStrategy.get(DEFAULT_TYPE);
        }
        return scheduleStrategy.get(schdulingtype);
    }
}
